home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: gusty@clark.net (Harlan Messinger)
- Newsgroups: comp.lang.c++
- Subject: Re: Is there a standard for * and & placement style?
- Date: 20 Feb 1996 14:04:21 GMT
- Organization: Clark Internet Services, Inc., Ellicott City, MD USA
- Message-ID: <4gckd5$bc7@clarknet.clark.net>
- References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
-
- Matt Arnold (marnold@netcom.com) wrote:
- : My personal preference is Form 1, and I have a logical reason: It
- : seems to me that that "pointer-ness" (*) or "reference-ness" (&) is
- : certinaly part of the variable *type*, not part of the variable. It
- : therefore seems logical to associate * or & with type identifier
- : rather than the variable name. For me, this creates a distinct
- : visual separation between types and variables.
-
- I agree with you that I would _like_ the * and the & to be appended to
- the base type. However, the syntax of pointer and reference type
- declarations itself associates the * and the & with the variable names,
- as can be seen when multiple variables are declared on the same line.
-
- char* p, q;
-
- may appear to declare two variables, each a (char*), but that is not the
- case. Instead, p is (char*) and q is char. To get both of them to be
- (char*), we need
-
- char *p, *q;
-
- Adding more complexity,
-
- char a, b, *c, *d, &e = a;
-
- declares a and b as char, c and d as (char*), and e as (char&).
-
- I think the syntax is dumb in the first place. One declaration statement
- should declare variables of one type. I think
-
- char* a, b, c;
-
- should declare three (char*) variables. If someone also wants a char
- variable d, then that should be on two lines:
-
- char *a, b, c;
- char d;
-
- But that's not what they gave us. For this reason, I've wound up using the
- "char *x" format, and it recently occurred to me, even though I've never
- declared multiple references on one line, that "char &y" would be
- consistent.
-
-